package com.easy.common.util.mail;

import java.util.Properties;

import com.easy.common.constant.SysProps;
import com.easy.common.util.Utility;
import com.easy.common.util.form.FOM;

public class MailSenderInfo
{
	private String mailServerHost = null;
	private String mailServerPort = "25";

	private String fromAddress = null;

	private String toAddress = null;

	private String userName = null;
	private String password = null;

	private boolean validate = false;

	private String subject = null;

	private String content = null;

	private String[] attachFileNames = null;

	public static MailSenderInfo build(String propKey) {
		String confProps = SysProps.getString(propKey);
		if (Utility.isNullorEmpty(confProps))return null;
		try
		{
			return (MailSenderInfo)FOM.json2Obj(confProps, MailSenderInfo.class); } catch (Exception ex) {
		}
		return null;
	}

	public Properties getProperties()
	{
		Properties p = new Properties();
		p.put("mail.smtp.host", this.mailServerHost);
		p.put("mail.smtp.port", this.mailServerPort);
		p.put("mail.smtp.auth", this.validate ? "true" : "false");
		return p;
	}

	public String getMailServerHost() {
		return this.mailServerHost;
	}

	public void setMailServerHost(String mailServerHost) {
		this.mailServerHost = mailServerHost;
	}

	public String getMailServerPort() {
		return this.mailServerPort;
	}

	public void setMailServerPort(String mailServerPort) {
		this.mailServerPort = mailServerPort;
	}

	public boolean isValidate() {
		return this.validate;
	}

	public void setValidate(boolean validate) {
		this.validate = validate;
	}

	public String[] getAttachFileNames() {
		return this.attachFileNames;
	}

	public void setAttachFileNames(String[] fileNames) {
		this.attachFileNames = fileNames;
	}

	public String getFromAddress() {
		return this.fromAddress;
	}

	public void setFromAddress(String fromAddress) {
		this.fromAddress = fromAddress;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getToAddress() {
		return this.toAddress;
	}

	public void setToAddress(String toAddress) {
		this.toAddress = toAddress;
	}

	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getSubject() {
		return this.subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getContent() {
		return this.content;
	}

	public void setContent(String textContent) {
		this.content = textContent;
	}
}